<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta charset="UTF-8">
	<title>分析决策/Analysis Resolution</title>
</head>
<link rel="stylesheet" href="css/style.css">
<!-- <link rel="stylesheet" href="layui/css/layui.css"  media="all"> -->
<link rel="stylesheet" href="css/normalize.css">
<body>
	<div class="nav">
		<div class="logo">
			<img src="images/logo.png" alt="">
		</div>
		<div class="nav_item">
			<a class="service" href="product.html">服务中心</a>
		</div>
		<div class="nav_item ">
			<a class="account" href="">账户管理</a>
		</div>
		<div class="nav_item cur">
			<a class="information" href="information.html">信息管理</a>
		</div>
	</div>
	<div class="navSide">
		<img src="images/sideIcon.png" alt="">
	</div>
	<div class="top clearfix">
		<span class="fr">欢迎回来，<span class='username'></span>! <a class="user" href="###"><span>A</span><i class="top_down"></i></a></span>
		<div class="navDown">
			<ul>
				<li><a href="###" class="quit">退出</a></li>
			</ul>
		</div>
	</div>
	
	<div class="con information">
		<div class="tab clearfix">
			<span class="infor_tab cur">全部信息</span>
			<span class="infor_tab">分析中</span>
			<span class="infor_tab">已完成</span>
		</div>
		<div class="main">
			<div class="infor_title infor_inner clearfix">
				<span>查询名称</span>
				<span>提交时间</span>
				<span>查询状态</span>
				<span></span>
			</div>
			<div id="infor_inner_box">

			</div>

		</div>
	</div>
	<div class="cover_box">
		<div class="cover_inf">
			<div class="cover_inf_title">
				状态概览
				<span>
					<img src="./images/close.png" alt="">
				</span>
			</div>
			<div id="cover_inf_content">

			</div>

		</div>
	</div>
</body>
<script src="layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/getAllTime.js"></script>
<script type="text/javascript" src="js/adaptation.js"></script>
<script type="text/javascript" src="js/ajax-information.js"></script>
<script type="text/javascript">
// <<<<<<< HEAD
// 	alert(index);
	// layui.use('layer',function(){
	// 	var $ =layui.jquery,layer =layui.layer;
	// 	var active ={
	// 		notice:function(){layer.open({
	// 			type:2
	// 			,skin: 'order'
	// 			,title: ['状态概览', 'text-align: center;color:#fff;background: #269ee4;font-weight:bold;padding: 0 80px 0 40px;border-radius: 10px 10px 0 0;']
	// 			,closeBtn:2
	// 			,shadeClose:false
	// 			,area:['720px', '450px']
	// 			,shade:0.6
	// 			,resize:false
	// 			,id:'LAY_layuipro1' 

	// 	// ,zIndex:2
	// 	,yes: function(index, layero){

	// 		// layer.open({
	// 		// 	title: false
	// 		// 	,type:2
	// 		// 	,area:['750px', '426px']
	// 		// 	,content:'paysucc.html'
	// 		// 	,zIndex:500000000000000
	// 		// });     
	// 		return true;
// =======
//	getData方法,url,infCenter,getData方法在ajax-information中，用于ajax请求数据获取
//getDates方法在getAllTime中
var ajaxUrl=url,
infCenterUrl=infCenter;
var	allInf={
	username:sessionStorage.getItem('username')
};

//用于存储获取到的所有的订单数据
var newResData;

//	根据不同状态显示不同的查询状态
var selectState=function(state,orderId){
	if(state=='2') return '<span class="infor_state infor_time">正在分析......</span>';
	if(state=='3') return '分析完成，<a class="a_blue" href="###" data-orderId='+orderId+'>点击查看结果</a>'+'</span>';
	if(state=='4') return '<span class="infor_state infor_time">订单失败</span>';
};

//生成dom元素
var tableInf=function(res){
	console.log(res);
	if ( res.errorCode == '0000000') {
		newResData=res.rows;
		var str='';
		for(var k in newResData){
			var orderName=newResData[k].orderName
			if (orderName=='') {
				orderName='&nbsp;';
			}
			str=
			'<div class="infor_inner clearfix">'+
			'<span class="infor_name">'+orderName+'</span>'+
			'<span class="infor_time">'+getDates(newResData[k].orderDate)+'</span>'+
			'<span class="infor_state">'+selectState(newResData[k].orderState,newResData[k].orderId)+'</span>'+
			'<span><a class="state" href="###" data-orderId="'+newResData[k].orderId+'"><i class="spot"></i></a></span>'+
			'</div>'+str
		};
		$('#infor_inner_box').append(str);
	}
};
getData('post',ajaxUrl,infCenterUrl,allInf,tableInf,$('#infor_inner_box'));


//信息中心详细信息获取并生成对应的dom
var infContent=function(clickData){
	console.log(clickData);
	var str='';
	str='<div class="statecon">'+
	'<div class="statetitle"><i class="stateicon"></i>订单编号</div>'+
	'<div class="staconbox">'+clickData.orderId+'</div>'+
	'</div>'+
	'<div class="statecon">'+
	'<div class="statetitle"><i class="stateicon"></i>用户需求</div>'+
	'<div class="staconbox">'+
	'<div class="demandinfo"><span>城市选择：<span class="grey">'+clickData.orderInfo.city+'</span></span></div>'+
	'<div class="demandinfo"><span>媒体类型：<span class="grey">'+clickData.orderInfo.media+'</span></span></div>'+
	'<div class="demandinfo"><span>投放周期：<span class="grey">'+clickData.orderInfo.putin+'</span></span></div>'+
	'<div class="demandinfo"><span>投入预算：<span class="grey">'+clickData.orderInfo.price+'</span></span></div>'+
	'<div class="demandinfo"><span>受众选择：<span class="grey">'+clickData.orderInfo.audience+'</span></span></div>'+
	'</div>'+
	'</div>';
	$('#cover_inf_content').append(str);
	$('.cover_box').addClass('active');
}

//	获取对应的orderId并跳转
$('#infor_inner_box').on('click','.a_blue',function(){
	var orderId=$(this).attr('data-orderId');
	sessionStorage.setItem('orderId',orderId);
	window.location.href='city.html';
})

//获取对应的orderId并填入详情
$('#infor_inner_box').on('click','.state',function(){
	var orderId=$(this).attr('data-orderId');
	var clickData;
//		获取对应订单号的数据
for(var k in newResData){
	if(newResData[k].orderId==orderId){
		clickData=newResData[k]
	}
}
infContent(clickData)
});

//	关闭弹出框并清楚弹框中的详细信息
$('.cover_inf_title span').on('click',function(){
	$('.cover_box').removeClass('active');
	$('#cover_inf_content').children().remove();
});


//tab切换，根据不同的orderState，获取不同的数据，生成对应的列表
$('.infor_tab').click(function(){
	$('#infor_inner_box').children().remove();
	var thisName=$(this).text().trim();
	var allInf;
	if(thisName=='全部信息'){
		allInf={
			username:sessionStorage.getItem('username')
		};
	}else if(thisName=='分析中'){
		allInf={
			username:sessionStorage.getItem('username'),
			orderState:'2'
		};
	}else if(thisName=='已完成'){
		allInf={
			username:sessionStorage.getItem('username'),
			orderState:'3'
		};
	}

	getData('post',ajaxUrl,infCenterUrl,allInf,tableInf,$('#infor_inner_box'));

	$(this).addClass('cur').siblings().removeClass('cur');

})
</script>
</html>